package com.example.config;

import com.example.book.BookRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
@ComponentScan(basePackages = "com.example.book")
public class SpringConfig2 {

    @Primary //在没有明确指定注入哪个时，Primary修饰的bean优先级最高
    @Bean(value = "bookRepository2")
    public BookRepository bookRepository() {
        BookRepository bookRepository = new BookRepository();
        bookRepository.setMaxConnection(20);
        return bookRepository;
    }

}



